package com.zhilei.service.impl;

import com.zhilei.base.BaseInfoProperties;
import com.zhilei.mapper.SysParamsMapper;
import com.zhilei.pojo.SysParams;
import com.zhilei.service.SysParamsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 资源表 服务实现类
 * </p>
 *
 * @author 志磊
 * @since 2024-09-22
 */
@Slf4j
@Service
public class SysParamsServiceImpl extends BaseInfoProperties implements SysParamsService {

    @Autowired
    private SysParamsMapper sysParamsMapper;

    /**
     * 设置最大简历得刷新次数
     *
     * @param maxCounts 简历刷新次数
     * @param version   版本号
     * @return
     */
    @Override
    public void modifyMaxResumeRefreshCounts(Integer maxCounts, Integer version) {
        SysParams sysParams = new SysParams();
        if (maxCounts != null) {
            // 固定id为1001，保证只有一个参数记录
            sysParams.setId(1001);
            sysParams.setMaxResumeRefreshCounts(maxCounts);
            sysParamsMapper.updateById(sysParams);
        } else {
            sysParams.setId(1001);
            sysParams.setMaxResumeRefreshCounts(maxCounts);
            sysParamsMapper.insert(sysParams);
        }

    }

    /**
     * 查询参数内容
     *
     * @return
     */
    @Override
    public SysParams getParams() {
        SysParams sysParams = sysParamsMapper.selectById(1001);
        return sysParams;
    }
}
